import Home from '@/views/Home' // 主页
import Cart from '@/views/Cart' // 订单
import Mine from '@/views/Mine' // 个人中心
import Search from '@/views/Search' // 搜索页面
import Login from '@/views/Login' // 登录页面

import Navbar from '@/components/Navbar' // 顶部复用
import Tabbar from '@/components/Tabbar' // 底部复用

const routes = [
  {
    path: '/home',
    name: 'Home',
    components: {
      default: Home,
      footer: Tabbar,
    },
  },
  {
    path: '/cart',
    name: 'Cart',
    components: {
      default: Cart,
      footer: Tabbar,
    },
    children: [
      {
        path: '/cart/sub',
        component: () => import('@/views/carts'),
      },
      {
        path: '/cart',
        redirect: '/cart/sub',
      },
    ],
  },
  {
    path: '/mine',
    name: 'Mine',
    components: {
      default: Mine,
      footer: Tabbar,
    },
  },
  {
    path: '/search',
    name: 'Serach',
    components: {
      header: Navbar,
      default: Search,
      footer: Tabbar,
    },
    meta: {
      title: '搜索页',
    },
  },
  {
    path: '/login',
    name: 'Login',
    components: {
      default: Login,
    },
  },
  // 详情
  {
    path: '/details',
    name: 'details',
    component: () => import('@/views/Details'),
    children: [
      {
        path: '/details/sub',
        component: () => import('@/views/details/index'),
        children: [
          {
            path: '/details/sub/:id',
            name: 'son',
            component: () => import('@/views/details/son'),
          },
        ],
      },
      {
        path: '/details/sub2',
        component: () => import('@/views/details/Kong'),
      },
      {
        path: '/details',
        redirect: '/details/sub/0',
      },
    ],
  },
  {
    path: '*',
    redirect: '/home', // 重定向
  },
]
export default routes
